<?php

if ($data->isThumbnail()) {
	$thumbnail = $data;
} else {
	if (!file_exists($data->thumbnailPath)) {
		$data->saveAsJpeg($data->thumbnailPath, 100, 100, true, 50);
	}
	$thumbnail = new ImageFile($data->thumbnailPath);
}

$baseUrl = Yii::app()->request->baseUrl;

$path = $path ? "$path/" : '';
$src = "$baseUrl/files/$type/$path$thumbnail->basename";
$text = "<img src=\"$src\" class=\"thumbnail hover\" />";

$url = "$baseUrl/files/$type/$path$data->basename";
$htmlOptions = array('title'=>$data->filename);
echo CHtml::link($text, $url, $htmlOptions);
